package org.mseco.doc.expensetrack.util;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;

import android.util.Log;

public class FormatUtil {
	public static final String DATE_FORMAT = "yyyy/MM/dd HH:mm";
	private static DateFormat dateFormat = new SimpleDateFormat(DATE_FORMAT,Locale.US);
	
	public static String format(long value){
		return String.format(Locale.US,"%,8d",value);
	}
	
	public static String dateToString(Date date){	
		return dateFormat.format(date);	
	}
	
	
	public static Date stringToDate(String date){
		try {
			return dateFormat.parse(date);
		} catch (ParseException e) {
			Log.e("date format not recognized:" + date,"Working with current date");
			return new Date();
		}
	}
}
